package com.company.restaurant.service.convertor;

import com.company.restaurant.dto.BaseMessage;
import com.company.restaurant.dto.LoginRequest;
import com.company.restaurant.dto.MessageIds;
import com.company.restaurant.dto.Protocol;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

/**
 * Description of class.
 * Created 5/16/14 2:26 PM
 *
 * @author andrey.rodin@playtech.com
 */

public final class ConverterManager {

    private static Map<MessageIds, Converter> protocolConverterMap = new HashMap<>();
    static {
        protocolConverterMap.put(MessageIds.LOGIN_REQUEST, new JsonConverter(LoginRequest.class));
    }

    public static BaseMessage processConverter(MessageIds messageIds, Serializable source) {
        Converter converter = protocolConverterMap.get(messageIds);
        return converter.convert(source);
    }
}
